﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace YArchitech.Plumbing
{
	public class HYPumpData
	{
		[Category("属性列表")]
		[DisplayName("型号")]
		[ReadOnly(true)]
		public string StrSpecification
		{
			get
			{
				return this.strSpecification;
			}
			set
			{
				this.strSpecification = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("厂家")]
		[ReadOnly(true)]
		public string StrFactory
		{
			get
			{
				return this.strFactory;
			}
			set
			{
				this.strFactory = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("系列类型名")]
		[ReadOnly(true)]
		public string StrTypeInFactory
		{
			get
			{
				return this.strTypeInFactory;
			}
			set
			{
				this.strTypeInFactory = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("基本类型")]
		[ReadOnly(true)]
		public string StrBaseType
		{
			get
			{
				return this.strBaseType;
			}
			set
			{
				this.strBaseType = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("结构类型")]
		[ReadOnly(true)]
		public string StrStructType
		{
			get
			{
				return this.strStructType;
			}
			set
			{
				this.strStructType = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("安装形式")]
		[ReadOnly(true)]
		public string StrFitType
		{
			get
			{
				return this.strFitType;
			}
			set
			{
				this.strFitType = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("流量(m3/h)")]
		[ReadOnly(true)]
		public double DQ
		{
			get
			{
				return this.dQ;
			}
			set
			{
				this.dQ = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("扬程(m)")]
		[ReadOnly(true)]
		public double DH
		{
			get
			{
				return this.dH;
			}
			set
			{
				this.dH = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("效率(%)")]
		[ReadOnly(true)]
		public double DEffection
		{
			get
			{
				return this.dEffection;
			}
			set
			{
				this.dEffection = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("转速(r/min)")]
		[ReadOnly(true)]
		public int NRotSpeed
		{
			get
			{
				return this.nRotSpeed;
			}
			set
			{
				this.nRotSpeed = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("轴功率(kW)")]
		[ReadOnly(true)]
		public double DPumpPower
		{
			get
			{
				return this.dPumpPower;
			}
			set
			{
				this.dPumpPower = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("进口管径(mm)")]
		[ReadOnly(true)]
		public double DIn
		{
			get
			{
				return this.dIn;
			}
			set
			{
				this.dIn = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("出口管径(mm)")]
		[ReadOnly(true)]
		public double DOut
		{
			get
			{
				return this.dOut;
			}
			set
			{
				this.dOut = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("电机功率(kW)")]
		[ReadOnly(true)]
		public double DEnginPower
		{
			get
			{
				return this.dEnginPower;
			}
			set
			{
				this.dEnginPower = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("电机型号")]
		[ReadOnly(true)]
		public string StrEnginSpecfication
		{
			get
			{
				return this.strEnginSpecfication;
			}
			set
			{
				this.strEnginSpecfication = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("工作电压(V)")]
		[ReadOnly(true)]
		public double DVoltage
		{
			get
			{
				return this.dVoltage;
			}
			set
			{
				this.dVoltage = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("叶轮位置")]
		[ReadOnly(true)]
		public string StrImpellerPos
		{
			get
			{
				return this.strImpellerPos;
			}
			set
			{
				this.strImpellerPos = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("最大承压(m)")]
		[ReadOnly(true)]
		public double DMaxPressure
		{
			get
			{
				return this.dMaxPressure;
			}
			set
			{
				this.dMaxPressure = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("用途")]
		[ReadOnly(true)]
		public string StrUse
		{
			get
			{
				return this.strUse;
			}
			set
			{
				this.strUse = value;
			}
		}

		[Browsable(false)]
		public bool BDrawbyself
		{
			get
			{
				return this.bDrawbyself;
			}
			set
			{
				this.bDrawbyself = value;
			}
		}

		[Browsable(false)]
		public bool BResistcorrosion
		{
			get
			{
				return this.bResistcorrosion;
			}
			set
			{
				this.bResistcorrosion = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("是否自吸")]
		[ReadOnly(true)]
		public string ChineseBDrawbyself
		{
			get
			{
				if (this.bDrawbyself)
				{
					return "是";
				}
				return "否";
			}
		}

		[Category("属性列表")]
		[DisplayName("是否耐腐蚀")]
		[ReadOnly(true)]
		public string ChineseBResistcorrosion
		{
			get
			{
				if (this.bResistcorrosion)
				{
					return "是";
				}
				return "否";
			}
		}

		[Category("属性列表")]
		[DisplayName("泵体材料")]
		[ReadOnly(true)]
		public string StrMaterial
		{
			get
			{
				return this.strMaterial;
			}
			set
			{
				this.strMaterial = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("重量(kg)")]
		[ReadOnly(true)]
		public double DWeight
		{
			get
			{
				return this.dWeight;
			}
			set
			{
				this.dWeight = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("最低工作温度(。C)")]
		[ReadOnly(true)]
		public double DMinTemperature
		{
			get
			{
				return this.dMinTemperature;
			}
			set
			{
				this.dMinTemperature = value;
			}
		}

		[Category("属性列表")]
		[DisplayName("最高工作温度(。C)")]
		[ReadOnly(true)]
		public double DMaxTemperature
		{
			get
			{
				return this.dMaxTemperature;
			}
			set
			{
				this.dMaxTemperature = value;
			}
		}

		public virtual bool AnalyseCurve(bool bFitCurve = true)
		{
			this.AnalyseCurve(this.stringHCurve, this.nHCurveIndex, ref this.m_CurveQ2H, -1.0);
			this.AnalyseCurve(this.stringNCurve, this.nNCurveIndex, ref this.m_CurveQ2N, -1.0);
			this.AnalyseCurve(this.stringECurve, this.nECurveIndex, ref this.m_CurveQ2Eff, -1.0);
			this.AnalyseCurve(this.stringNPSHCurve, this.nNPSHCurveIndex, ref this.m_CurveQ2NPSH, this.dVacuum);
			if (bFitCurve)
			{
				this.FitCurve();
			}
			return true;
		}

		public bool AnalyseCurve(string strCurve, int nExpIndex, ref HYPumpOperationCurveData curvedata, double dValueIfNone = -1.0)
		{
			curvedata.Clear();
			curvedata.m_nTimes = nExpIndex;
			List<stCurvePt> list = new List<stCurvePt>();
			Dictionary<string, string> dictionary = HYPumpDataManager.ConvertStringToDic(strCurve);
			if (dictionary.Count > 2)
			{
				using (Dictionary<string, string>.Enumerator enumerator = dictionary.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<string, string> keyValuePair = enumerator.Current;
						double dK = Convert.ToDouble(keyValuePair.Key);
						double dV = Convert.ToDouble(keyValuePair.Value);
						list.Add(new stCurvePt(dK, dV));
					}
					goto IL_D5;
				}
			}
			double first = this.m_CurveQ2H.m_curveLeftPt.first;
			double num = (this.m_CurveQ2H.m_curveRightPt.first - first) / 4.0;
			for (int i = 0; i < 5; i++)
			{
				double dK2 = first + (double)i * num;
				list.Add(new stCurvePt(dK2, dValueIfNone));
			}
			IL_D5:
			curvedata.SetByPtCurveArr(ref list);
			return true;
		}

		public bool FitCurve()
		{
			bool flag = this.m_CurveQ2H.FitCurveParam();
			bool flag2 = this.m_CurveQ2N.FitCurveParam();
			bool flag3 = this.m_CurveQ2Eff.FitCurveParam();
			bool flag4 = this.m_CurveQ2NPSH.FitCurveParam();
			return flag && flag2 && flag3 && flag4;
		}

		public virtual double GetMaxQ()
		{
			if (this.m_CurveQ2H.IsEmpty())
			{
				return this.dQ;
			}
			double num = -1.0;
			double num2 = -1.0;
			if (!this.m_CurveQ2H.GetMaxQandValue(ref num, ref num2))
			{
				return this.dQ;
			}
			if (num <= this.dQ)
			{
				return this.dQ;
			}
			return num;
		}

		public virtual double GetMaxH()
		{
			if (this.m_CurveQ2H.IsEmpty())
			{
				return this.dH;
			}
			double num = -1.0;
			double num2 = -1.0;
			if (!this.m_CurveQ2H.GetMaxValue(ref num, ref num2))
			{
				return this.dH;
			}
			if (num <= this.dH)
			{
				return this.dH;
			}
			return num;
		}

		public virtual double GetHbyQ(double d)
		{
			if (this.dQ == d)
			{
				return this.dH;
			}
			if (!this.m_CurveQ2H.IsEmpty())
			{
				return this.m_CurveQ2H.CalCurveValue(d);
			}
			return this.dH;
		}

		public virtual double GetNbyQ(double d)
		{
			if (this.dQ == d)
			{
				return this.dPumpPower;
			}
			if (!this.m_CurveQ2N.IsEmpty())
			{
				return this.m_CurveQ2N.CalCurveValue(d);
			}
			return this.dPumpPower;
		}

		public virtual double GetEbyQ(double d)
		{
			if (this.dQ == d)
			{
				return this.dEffection;
			}
			if (!this.m_CurveQ2Eff.IsEmpty())
			{
				return this.m_CurveQ2Eff.CalCurveValue(d);
			}
			return this.dEffection;
		}

		public virtual double GetVaccumbyQ(double d)
		{
			if (this.dQ == d)
			{
				return this.dVacuum;
			}
			if (!this.m_CurveQ2NPSH.IsEmpty())
			{
				return this.m_CurveQ2NPSH.CalCurveValue(d);
			}
			return this.dVacuum;
		}

		public bool IsIn(HYPumpRange pumprange)
		{
			bool flag = this.dQ <= pumprange.m_dMaxQ && this.dQ >= pumprange.m_dMinQ;
			bool flag2 = this.dH <= pumprange.m_dMaxH && this.dH >= pumprange.m_dMinH;
			bool flag3 = this.dEffection <= pumprange.m_dMaxE && this.dEffection >= pumprange.m_dMinE;
			return flag && flag2 && flag3;
		}

		public HYPumpOperationCurveData GetCurveAbout(EPumpCurveType curveType)
		{
			switch (curveType)
			{
			case EPumpCurveType.ePumpCurve_H:
				return this.m_CurveQ2H;
			case EPumpCurveType.ePumpCurve_N:
				return this.m_CurveQ2N;
			case EPumpCurveType.ePumpCurve_E:
				return this.m_CurveQ2Eff;
			case EPumpCurveType.ePumpCurve_NPSH:
				return this.m_CurveQ2NPSH;
			default:
				return this.m_CurveQ2H;
			}
		}

		public string strIdentifier;

		private string strSpecification;

		private string strFactory;

		private string strTypeInFactory;

		private string strBaseType;

		private string strStructType;

		private string strFitType;

		private double dQ;

		private double dH;

		private double dEffection;

		private int nRotSpeed;

		private double dPumpPower;

		private double dIn;

		private double dOut;

		private double dEnginPower;

		private string strEnginSpecfication;

		private double dVoltage;

		private string strImpellerPos;

		private double dMaxPressure;

		private string strUse;

		private bool bDrawbyself;

		private bool bResistcorrosion;

		private string strMaterial;

		private double dWeight;

		private double dMinTemperature;

		private double dMaxTemperature;

		public EVacuumType eVacuumType;

		public double dVacuum;

		public double dHeight;

		public double dLength;

		public double dWidth;

		public double dInMInPressure;

		public string strFlowtype;

		public bool bPefectSeal;

		public bool bExplosionProof;

		public bool bIsCuttedByFactory;

		public int nOriginSpeed;

		public double dCutRate;

		public string strFitRvtName;

		public string strBaseParam;

		public string strDampBaseParam;

		public string stringHCurve;

		public string stringNCurve;

		public string stringECurve;

		public string stringNPSHCurve;

		public int nHCurveIndex = 2;

		public int nNCurveIndex = 3;

		public int nECurveIndex = 3;

		public int nNPSHCurveIndex = 3;

		public HYPumpOperationCurveData m_CurveQ2H = new HYPumpOperationCurveData();

		public HYPumpOperationCurveData m_CurveQ2N = new HYPumpOperationCurveData();

		public HYPumpOperationCurveData m_CurveQ2Eff = new HYPumpOperationCurveData();

		public HYPumpOperationCurveData m_CurveQ2NPSH = new HYPumpOperationCurveData();

		public string strFamily;

		public string strImage2D;

		public string strImage3D;

		public stCurvePt m_leftPt = new stCurvePt();

		public stCurvePt m_rightPt = new stCurvePt();
	}
}
